<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class PocketLog extends Model
{
    protected $fillable = [
        'customer_id',
        'money',
        'direct',
        'comment',
    ];

    protected $hidden = [
        'customer_id',
        'id',
        'updated_at'
    ];

    public static function log($customerId, int $money, string $comment, bool $direct = true)
    {
        return static::create([
            'customer_id' => $customerId,
            'money' => $money,
            'direct' => (int)$direct,
            'comment' => $comment,
        ]);
    }

    public function getMoneyAttribute($money)
    {
        return price($money / 100);
    }
}
